local spTable = {
  [458] = 4914,
  [463] = 5152,
  [466] = 5293,
  [470] = 5496,
  [471] = 5550,
  [474] = 5704,
  [476] = 5812,
  [478] = 5920,
  [480] = 6032,
  [483] = 6206,
  [484] = 6261,
  [487] = 6441,
  [489] = 6564,
  [490] = 6628,
  [491] = 6685,
  [493] = 6812,
  [494] = 6879,
  [496] = 7007,
  [497] = 7071,
  [498] = 7140,
  [500] = 7272,
  [501] = 7337,
  [502] = 7408,
  [503] = 7478,
  [504] = 7548,
  [505] = 7619,
  [506] = 7688,
  [507] = 7761,
  [508] = 7836,
  [509] = 7907,
  [510] = 7980,
  [511] = 8054,
  [512] = 8132,
  [513] = 8206,
  [514] = 8286,
  [515] = 8364,
  [516] = 8441,
  [517] = 8518,
  [518] = 8603,
  [519] = 8680,
  [520] = 8761,
  [521] = 8841,
  [524] = 9093,
  [525] = 9179,
  [528] = 9439,
  [532] = 9797,
}
local upTable = {
  [1]   =  8, -- 1/1
  [373] =  4, -- 1/2
  [374] =  8, -- 2/2
  [375] =  4, -- 1/3
  [376] =  4, -- 2/3
  [377] =  4, -- 3/3
  [379] =  4, -- 1/2
  [380] =  4, -- 2/2
  [445] =  0, -- 0/2
  [446] =  4, -- 1/2
  [447] =  8, -- 2/2
  [451] =  0, -- 0/1
  [452] =  8, -- 1/1
  [453] =  0, -- 0/2
  [454] =  4, -- 1/2
  [455] =  8, -- 2/2
  [456] =  0, -- 0/1
  [457] =  8, -- 1/1
  [458] =  0, -- 0/4
  [459] =  4, -- 1/4
  [460] =  8, -- 2/4
  [461] = 12, -- 3/4
  [462] = 16, -- 4/4
}
function GetItemStatsUp(link, table)
  local result = GetItemStats(link, table)
  if not result then
    return result
  end
  local id = tonumber (link:match ("item:%d+:%d+:%d+:%d+:%d+:%d+:%-?%d+:%-?%d+:%d+:%d+:(%d+)"))
  local _, _, _, iLvl = GetItemInfo(link)
  iLvl = iLvl or 0
  if iLvl >= 458 and upTable[id] then
    local iLvl2 = iLvl + upTable[id]
    if iLvl2 > iLvl and spTable[iLvl] and spTable[iLvl2] then
      for k, v in pairs(result) do
        if tonumber(v) then
          result[k] = math.floor(tonumber(v) * spTable[iLvl2] / spTable[iLvl] + 0.5)
        end
      end
    end
  end
  return result
end

ReforgeLiteScalingTable = {
  -- Credits to SimulationCraft
  -- Spirit dummy
  {},
  -- Dodge rating multipliers
  {
       0.796153187751770,    0.796153068542480,    0.796153068542480,    0.796153068542480,    0.796152949333191,
       0.796153128147125,    0.796153068542480,    0.796153008937836,    0.796153008937836,    0.796153128147125,
       1.194230556488037,    1.592308163642883,    1.990383744239807,    2.388461112976074,    2.786539077758789,
       3.184616804122925,    3.582691907882690,    3.980769872665405,    4.378847599029541,    4.776922702789307,
       5.175000190734863,    5.573077678680420,    5.971153259277344,    6.369230747222900,    6.767308712005615,
       7.165383338928223,    7.563461780548096,    7.961538791656494,    8.359617233276367,    8.757692337036133,
       9.155768394470215,    9.553846359252930,    9.951925277709961,   10.350001335144043,   10.748077392578125,
      11.146153450012207,   11.544231414794922,   11.942307472229004,   12.340383529663086,   12.738462448120117,
      13.136537551879883,   13.534616470336914,   13.932692527770996,   14.330768585205078,   14.728846549987793,
      15.126925468444824,   15.524999618530273,   15.923077583312988,   16.321155548095703,   16.719230651855469,
      17.117309570312500,   17.515386581420898,   17.913461685180664,   18.311538696289062,   18.709617614746094,
      19.107692718505859,   19.505769729614258,   19.903848648071289,   20.301923751831055,   20.700000762939453,
      21.486076354980469,   22.334213256835938,   23.252056121826172,   24.248571395874023,   25.334329605102539,
      26.521877288818359,   27.826231002807617,   29.265518188476562,   30.861820220947266,   32.642307281494141,
      35.121570587158203,   37.789138793945312,   40.659320831298828,   43.747493743896484,   47.070220947265625,
      50.645320892333984,   54.491958618164062,   58.630756378173828,   63.083904266357422,   67.875282287597656,
      89.125953674316406,  117.037277221679688,  153.750198364257812,  201.881378173828125,  265.078338623046875,
     335.000000000000000,  430.000000000000000,  545.000000000000000,  700.000000000000000,  885.000000000000000,
  },
  -- Parry rating multipliers
  {
       0.796153187751770,    0.796153068542480,    0.796153068542480,    0.796153068542480,    0.796152949333191,
       0.796153128147125,    0.796153068542480,    0.796153008937836,    0.796153008937836,    0.796153128147125,
       1.194230556488037,    1.592308163642883,    1.990383744239807,    2.388461112976074,    2.786539077758789,
       3.184616804122925,    3.582691907882690,    3.980769872665405,    4.378847599029541,    4.776922702789307,
       5.175000190734863,    5.573077678680420,    5.971153259277344,    6.369230747222900,    6.767308712005615,
       7.165383338928223,    7.563461780548096,    7.961538791656494,    8.359617233276367,    8.757692337036133,
       9.155768394470215,    9.553846359252930,    9.951925277709961,   10.350001335144043,   10.748077392578125,
      11.146153450012207,   11.544231414794922,   11.942307472229004,   12.340383529663086,   12.738462448120117,
      13.136537551879883,   13.534616470336914,   13.932692527770996,   14.330768585205078,   14.728846549987793,
      15.126925468444824,   15.524999618530273,   15.923077583312988,   16.321155548095703,   16.719230651855469,
      17.117309570312500,   17.515386581420898,   17.913461685180664,   18.311538696289062,   18.709617614746094,
      19.107692718505859,   19.505769729614258,   19.903848648071289,   20.301923751831055,   20.700000762939453,
      21.486076354980469,   22.334213256835938,   23.252056121826172,   24.248571395874023,   25.334329605102539,
      26.521877288818359,   27.826231002807617,   29.265518188476562,   30.861820220947266,   32.642307281494141,
      35.121570587158203,   37.789138793945312,   40.659320831298828,   43.747493743896484,   47.070220947265625,
      50.645320892333984,   54.491958618164062,   58.630756378173828,   63.083904266357422,   67.875282287597656,
      89.125953674316406,  117.037277221679688,  153.750198364257812,  201.881378173828125,  265.078338623046875,
     335.000000000000000,  430.000000000000000,  545.000000000000000,  700.000000000000000,  885.000000000000000,
  },
  -- Hit rating multipliers
  {
       0.307691991329193,    0.307691991329193,    0.307691991329193,    0.307691991329193,    0.307691991329193,
       0.307691991329193,    0.307691991329193,    0.307691991329193,    0.307691991329193,    0.307691991329193,
       0.461537986993790,    0.615384995937347,    0.769231021404266,    0.923076987266541,    1.076923012733459,
       1.230769038200378,    1.384614944458008,    1.538462042808533,    1.692307949066162,    1.846153974533081,
       2.000000000000000,    2.153846025466919,    2.307692050933838,    2.461539030075073,    2.615385055541992,
       2.769231081008911,    2.923077106475830,    3.076922893524170,    3.230768918991089,    3.384614944458008,
       3.538461923599243,    3.692307949066162,    3.846153974533081,    4.000000000000000,    4.153845787048340,
       4.307692050933838,    4.461537837982178,    4.615385055541992,    4.769230842590332,    4.923077106475830,
       5.076922893524170,    5.230769157409668,    5.384614944458008,    5.538462162017822,    5.692306995391846,
       5.846154212951660,    6.000000000000000,    6.153845787048340,    6.307693004608154,    6.461537837982178,
       6.615385055541992,    6.769230842590332,    6.923077106475830,    7.076922893524170,    7.230769157409668,
       7.384614944458008,    7.538462162017822,    7.692306995391846,    7.846154212951660,    8.000000000000000,
       8.303797721862793,    8.631579399108887,    8.986301422119141,    9.371427536010742,    9.791045188903809,
      10.250000000000000,   10.754098892211914,   11.310345649719238,   11.927273750305176,   12.615385055541992,
      13.573554992675781,   14.604499816894531,   15.713747978210449,   16.907243728637695,   18.191390991210938,
      19.573070526123047,   21.059694290161133,   22.659227371215820,   24.380252838134766,   26.231992721557617,
      34.444812774658203,   45.231800079345703,   59.420368194580078,   78.021789550781250,  102.445739746093750,
     130.000000000000000,  166.000000000000000,  211.000000000000000,  269.000000000000000,  340.000000000000000,
  },
  -- Crit rating multipliers
  {
       0.538461983203888,    0.538461983203888,    0.538461983203888,    0.538461983203888,    0.538461983203888,
       0.538461983203888,    0.538461983203888,    0.538461983203888,    0.538461983203888,    0.538461983203888,
       0.807691991329193,    1.076923012733459,    1.346153974533081,    1.615385055541992,    1.884614944458008,
       2.153846025466919,    2.423077106475830,    2.692307949066162,    2.961538076400757,    3.230768918991089,
       3.500000000000000,    3.769231081008911,    4.038462162017822,    4.307692050933838,    4.576922893524170,
       4.846154212951660,    5.115385055541992,    5.384614944458008,    5.653845787048340,    5.923077106475830,
       6.192306995391846,    6.461537837982178,    6.730769157409668,    7.000000000000000,    7.269230842590332,
       7.538462162017822,    7.807693004608154,    8.076923370361328,    8.346154212951660,    8.615384101867676,
       8.884614944458008,    9.153845787048340,    9.423076629638672,    9.692307472229004,    9.961538314819336,
      10.230770111083984,   10.500000000000000,   10.769231796264648,   11.038461685180664,   11.307692527770996,
      11.576923370361328,   11.846155166625977,   12.115385055541992,   12.384616851806641,   12.653846740722656,
      12.923078536987305,   13.192308425903320,   13.461539268493652,   13.730770111083984,   14.000000000000000,
      14.531646728515625,   15.105264663696289,   15.726029396057129,   16.399999618530273,   17.134328842163086,
      17.937500000000000,   18.819673538208008,   19.793104171752930,   20.872728347778320,   22.076923370361328,
      23.753721237182617,   25.557874679565430,   27.499055862426758,   29.587677001953125,   31.834934234619141,
      34.252872467041016,   36.854465484619141,   39.653648376464844,   42.665439605712891,   45.905986785888672,
      60.278423309326172,   79.155647277832031,  103.985641479492188,  136.538131713867188,  179.280044555664062,
     228.000000000000000,  290.000000000000000,  370.000000000000000,  470.000000000000000,  600.000000000000000,
  },
  -- Haste rating multipliers
  {
       0.384615004062653,    0.384615004062653,    0.384615004062653,    0.384615004062653,    0.384615004062653,
       0.384615004062653,    0.384615004062653,    0.384615004062653,    0.384615004062653,    0.384615004062653,
       0.576923012733459,    0.769231021404266,    0.961538016796112,    1.153846025466919,    1.346153974533081,
       1.538462042808533,    1.730769038200378,    1.923076987266541,    2.115385055541992,    2.307692050933838,
       2.500000000000000,    2.692307949066162,    2.884614944458008,    3.076922893524170,    3.269231081008911,
       3.461538076400757,    3.653846025466919,    3.846153974533081,    4.038462162017822,    4.230769157409668,
       4.423077106475830,    4.615385055541992,    4.807693004608154,    5.000000000000000,    5.192307949066162,
       5.384614944458008,    5.576922893524170,    5.769230842590332,    5.961537837982178,    6.153845787048340,
       6.346154212951660,    6.538462162017822,    6.730769157409668,    6.923077106475830,    7.115385055541992,
       7.307693004608154,    7.500000000000000,    7.692306995391846,    7.884614944458008,    8.076923370361328,
       8.269230842590332,    8.461538314819336,    8.653845787048340,    8.846154212951660,    9.038461685180664,
       9.230769157409668,    9.423076629638672,    9.615385055541992,    9.807692527770996,   10.000000000000000,
      10.379747390747070,   10.789473533630371,   11.232876777648926,   11.714286804199219,   12.238806724548340,
      12.812500000000000,   13.442624092102051,   14.137930870056152,   14.909090995788574,   15.769232749938965,
      16.966941833496094,   18.255624771118164,   19.642183303833008,   21.134054183959961,   22.739236831665039,
      24.466339111328125,   26.324617385864258,   28.324035644531250,   30.475315093994141,   32.789989471435547,
      43.056015014648438,   56.539749145507812,   74.275451660156250,   97.527236938476562,  128.057159423828125,
     162.000000000000000,  208.000000000000000,  264.000000000000000,  336.000000000000000,  425.000000000000000,
  },
  -- Expertise rating multipliers
  {
       0.307691991329193,    0.307691991329193,    0.307691991329193,    0.307691991329193,    0.307691991329193,
       0.307691991329193,    0.307691991329193,    0.307691991329193,    0.307691991329193,    0.307691991329193,
       0.461537986993790,    0.615384995937347,    0.769231021404266,    0.923076987266541,    1.076923012733459,
       1.230769038200378,    1.384614944458008,    1.538462042808533,    1.692307949066162,    1.846153974533081,
       2.000000000000000,    2.153846025466919,    2.307692050933838,    2.461539030075073,    2.615385055541992,
       2.769231081008911,    2.923077106475830,    3.076922893524170,    3.230768918991089,    3.384614944458008,
       3.538461923599243,    3.692307949066162,    3.846153974533081,    4.000000000000000,    4.153845787048340,
       4.307692050933838,    4.461537837982178,    4.615385055541992,    4.769230842590332,    4.923077106475830,
       5.076922893524170,    5.230769157409668,    5.384614944458008,    5.538462162017822,    5.692306995391846,
       5.846154212951660,    6.000000000000000,    6.153845787048340,    6.307693004608154,    6.461537837982178,
       6.615385055541992,    6.769230842590332,    6.923077106475830,    7.076922893524170,    7.230769157409668,
       7.384614944458008,    7.538462162017822,    7.692306995391846,    7.846154212951660,    8.000000000000000,
       8.303797721862793,    8.631579399108887,    8.986301422119141,    9.371427536010742,    9.791045188903809,
      10.250000000000000,   10.754098892211914,   11.310345649719238,   11.927273750305176,   12.615385055541992,
      13.573554992675781,   14.604499816894531,   15.713747978210449,   16.907243728637695,   18.191390991210938,
      19.573070526123047,   21.059694290161133,   22.659227371215820,   24.380252838134766,   26.231992721557617,
      34.444812774658203,   45.231800079345703,   59.420368194580078,   78.021789550781250,  102.445739746093750,
     130.000000000000000,  166.000000000000000,  211.000000000000000,  269.000000000000000,  340.000000000000000,
  },
  -- Mastery rating multipliers
  {
       0.538461983203888,    0.538461983203888,    0.538461983203888,    0.538461983203888,    0.538461983203888,
       0.538461983203888,    0.538461983203888,    0.538461983203888,    0.538461983203888,    0.538461983203888,
       0.807691991329193,    1.076923012733459,    1.346153974533081,    1.615385055541992,    1.884614944458008,
       2.153846025466919,    2.423077106475830,    2.692307949066162,    2.961538076400757,    3.230768918991089,
       3.500000000000000,    3.769231081008911,    4.038462162017822,    4.307692050933838,    4.576922893524170,
       4.846154212951660,    5.115385055541992,    5.384614944458008,    5.653845787048340,    5.923077106475830,
       6.192306995391846,    6.461537837982178,    6.730769157409668,    7.000000000000000,    7.269230842590332,
       7.538462162017822,    7.807693004608154,    8.076923370361328,    8.346154212951660,    8.615384101867676,
       8.884614944458008,    9.153845787048340,    9.423076629638672,    9.692307472229004,    9.961538314819336,
      10.230770111083984,   10.500000000000000,   10.769231796264648,   11.038461685180664,   11.307692527770996,
      11.576923370361328,   11.846155166625977,   12.115385055541992,   12.384616851806641,   12.653846740722656,
      12.923078536987305,   13.192308425903320,   13.461539268493652,   13.730770111083984,   14.000000000000000,
      14.531646728515625,   15.105264663696289,   15.726029396057129,   16.399999618530273,   17.134328842163086,
      17.937500000000000,   18.819673538208008,   19.793104171752930,   20.872728347778320,   22.076923370361328,
      23.753721237182617,   25.557874679565430,   27.499055862426758,   29.587677001953125,   31.834934234619141,
      34.252872467041016,   36.854465484619141,   39.653648376464844,   42.665439605712891,   45.905986785888672,
      60.278423309326172,   79.155647277832031,  103.985641479492188,  136.538131713867188,  179.280044555664062,
     228.000000000000000,  290.000000000000000,  370.000000000000000,  470.000000000000000,  600.000000000000000,
  },
}
